<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    // 字面量
    var student ={
      name : "hb",
      age : "111111111111111111111",
      pin : function () {
        console.log(this.age,this.name);
      }
    }
    // new object()
    var student1 =new Object();
    student1.name = "shi";
    student1.age = 889;
    student1.ssname = function () {
      console.log(this.name);
    }
    student1.ssname();

    // 工厂函数
    function student2(name,age) {
      var stu = new Object();
      stu.name = name;
      stu.age = age;
      stu.fun = function () {
        console.log(this.name,this.age);
      }
    }
    function student3(name,age) {
      return {
        name : name,
        age:  age,
        fun : function () {
        console.log(this.name,this.age);
        }
      }
    }
    var sttu1 = student2("swsw",10010);
    var sttu2 = student2("aaa",2316);
    var sttu12 = student3("s1wsw",102010);
    var sttu22 = student3("aa1a",23216);
    sttu12.fun();
    var arr = [,1,1,1,1];
    console.log(arr instanceof Array);
    console.log(sttu12 instanceof student3);//工厂函数,普通函数返回false 构造函数返回true
    console.log(sttu1 instanceof student2)
  </script>
</body>
</html>